<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
 </head>
 <body>
  <form name="form1">
	<input type="text" name="text1"><input type="button" value="提交" onClick="check_value_has_space()">


  </form>
  <script>
	function check_value_has_space ()
	{
		var text1_str = document.form1.text1.value;
		var flag = 0;
		for (var i = 0; i < text1_str.length; i++)
		{
			if (text1_str[i] == " ")
			{
				flag = 1;
			}
		}
		if (1 == flag)
		{
			alert ("输入不能含有空格。");
		}
	}
  </script>
 </body>
</html>
